<?php
/**
 * Created by PhpStorm.
 * User: woody
 * Date: 17-2-16
 * Time: 下午10:46
 */

namespace App\Http\Controllers\Admin;

use App\Models\Recruit;
use Illuminate\Http\Request;

class RecruitController extends AdminController
{

    public function __construct()
    {
        parent::__construct();
        $this->_response['_active']['_model'] = 'recruit';
        $this->_response['_active']['_action'] = '';
        $this->_response['_title'] = '小一农货-招聘信息';
    }
    //招聘信息
    public function index(Request $request){
        $search=$request->all();
        $page = $request->get('page', 1);
        $this->_response['_active']['_action']      = 'list';

        $recruitList = new Recruit();
        $data = $recruitList->recruit($search, $page, 20);

        $this->_response['recruit'] = $data;

        $this->_response['recruit']['pageData']['page'] = $page;
        $this->_response['recruit']['pageData']['pageHtml'] = self::getPageHtml($page , $this->_response['recruit']['pageData']['lastPage'] , '/admin/recruit?');

        return view('admin.recruit.list', $this->_response);
    }
    //删除页面
    public function delete($id){
        $Del =[
            'deleted_at' => date('Y-m-d H:i:s', time())
        ];
        $recruitList = new Recruit();
        if($recruitList->Del($Del,$id)){
            return response()->json(['code' => 0, 'msg' => '删除成功']);
        }else{
            return response()->json(['code' => -1, 'msg' => '删除失败']);
        }
    }
}